home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
utils
/
xad
/
developer
/
include
/
autodocs
/
xadsub.doc
< prev
Wrap
Text File
|
1999-01-01
|
9KB
|
225 lines
TABLE OF CONTENTS
xadForeman/--Overview--
xadClient/--Overview--
xadClient/xcFree
xadClient/xcGetInfo
xadClient/xcRecogData
xadClient/xcUnArchive
VERSION
$VER: xadsub.doc 1.3 (14.03.1999) by SDI
xadForeman/--Overview-- xadForeman/--Overview--
The xadForeman structure is just some kind of header for external clients.
It protects the clients from being executed accidentally by having a small
piece of code (MOVEQ #-1,d0 : RTS) in the first 4 bytes.
The master can identify a valid bunch of external clients by checking the
first hunk of a file for the foreman identification.
Finally, a foreman holds the pointer to a linked list of clients and thus
enables the master to work with these clients.
xadClient/--Overview-- xadClient/--Overview--
The xadClient structure is the heart of the whole library system. Each
client enables the master to recognize and unarchive files.
Therefore each client contains 4 routines that are called from the master.
Pointers to these are stored in xc_RecogData, xc_GetInfo, xc_UnArchive and
xc_Free.
All routines have one thing in common: the CPU registers D0/D1/A0/A1 are
so-called scratch registers, they may change during execution, all other
registers must remain unchanged. CPU register A6 holds a pointer to the
xadMasterBase structure. See chapters below for a description of the client
routines.
ALL CLIENT ROUTINES MUST BE REENTRANT! NEVER STORE ANY DATA IN STATIC
MEMORY AREAS, USE THE STACK OR SOME ALLOCATED MEMORY INSTEAD! REMEMBER THAT
THE ROUTINES MIGHT BE CALLED BY SEVERAL PROGRAMS AT THE SAME TIME! DO
NOT EXCEED STACK USAGE (1KB SHOULD BE THE MAXIMUM), AS PROGRAMS NORMALLY
HAVE ONLY 4KB STACK.
The name of the archiver that is supported by the client and the flags that
describe the packer are stored in xc_ArchiverName and xc_Flags. Internal
clients all have an unique ID value stored in xc_Identifier. If you have
written a client that should replace an internal one, because it is faster
or otherwise enhanced, simply put the ID of the client to be replaced in
xc_Identifier. The old client will then be taken out of the list of used
clients. Normally this ID should be zero. There is one problem with this:
When the user deactivates external clients the xadmaster system is missing
this type completely as internal client is not activated in this case.
xcRecogData() usually only requires a quite small part of a file to
recognize it properly. To avoid reading the whole file for recognition
purposes, you need to set xc_RecogSize to the minimum amount of bytes
that is required to recognize the crunched file correctly.
Note that xadmaster uses this value internally to decide whether a file
might be archived with a archiver or not, so you don't have to do an extra
size comparison in your xc_RecogData function any more.
For archiver headers with non-constant sizes, simply set xc_RecogSize
to a value that will ensure correct recognition of all possible files.
Whenever you intend to use features of the xadmaster.library in your
clients that are marked (V2) or higher, make sure to set xc_MasterVersion
to the desired version number, otherwise an old library version might
crash while using the new client.
Whenever a client calls a xadmaster function and gets a return code, the
client needs to return this code! So whenever an error code is produced
somewhere, it must reach the calling program. This is most important
for progress report (automatically called by xadHookAccess), as the
XADERR_SKIP can be checked by calling program.
ANY needed structure must be allocated with xadAllocObject! None of the
XAD structures can be allocated any other way!
xadClient/xcFree xadClient/xcFree
NAME
xcFree -- Free all resources allocated by xcGetInfo
SYNOPSIS
xcFree(ai, xadMasterBase)
A0 A6
void xcFree(struct xadArchiveInfo *, struct xadMasterBase *)
FUNCTION
This function frees all the stuff allocated by xcGetInfo. It is
called after unsuccessful xcGetInfo as well, so you need not to
call any freeing functions there. But be prepared for that case.
You must check all entries, as xcGetInfo may fail in the first
allocation stages (f.e. allocation of xadDiskInfo or xadFileInfo
structures).
Clear all entries you have freed! There should not be any pointers
left in xadArchiveInfo structure which do not point to valid
memory.
INPUTS
ai the master communication structure
SEE ALSO
Example sourcecodes, xadmaster.library/xadFreeInfo()
xadClient/xcGetInfo xadClient/xcGetInfo
NAME
xcGetInfo -- create all information about an archive file
SYNOPSIS
result = xcGetInfo(ai, xadMasterBase)
D0 A0 A6
LONG xcGetInfo(struct xadArchiveInfo *, struct xadMasterBase *)
FUNCTION
This function is the most important one. It creates a structure
list containing all necessary information. File archivers create
a linked list of xadFileInfo structures for every file/link/
directory which is stored in the archive. xadAllocObject helps
to store that information by providing 3 tags for getting special
memory. XAD_OBJNAMESIZE can be used to allocate a buffer for
storing (also multiple) names. The buffer is byte aligned. Do not
forget to count the 0-byte for every string you want to store there.
The buffer pointer is stored in xfi_FileName.
XAD_OBJCOMMENTSIZE is equal to this, but stored in xfi_Comment.
For file and disk archives there is the flag XAD_OBJPRIVINFOSIZE,
which returns a longword aligned buffer in xfi_PrivateInfo or
xdi_PrivateInfo.
Disk archivers create a linked list of xadDiskInfo structures.
Normal disk archivers do not allow to store more than one archive,
so linking is most time not necessary, but it is supported.
When storing information texts, they must be finished with a zero
byte, which is not counted in size field!
Every file or disk entry gets an entrynumber, which increases from
first to last entry. For mixed archivers this means that a
"file, disk, disk, file, file, disk" archive gets file entry
numbers 1,4,5 and disk entry numbers 2,3,6.
Archivers may store XADAIF_FILECORRUPT flag in xai_Flags, when
archive is corrupt, but some entries are still usable. Unusable
entries must not appear in entry list.
Most disk archivers are based on cylinder structure. These should
fill the xadDiskInfo fields correctly. If archivers are not based
on it (e.g. only sector based) they need to set XADDIF_NOCYLINDER
flag!
If the archiver format does not support file dates, set the
current date (XAD_DATECURRENTIME tag) and XADFIF_NODATE flag.
Protection bits default to zero (equals "rwed").
INPUTS
ai master communication structure
RESULT
result - any of the XADERR codes or zero when all is ok.
SEE ALSO
Example sourcecodes, xadmaster.library/xadGetInfo()
xadClient/xcRecogData xadClient/xcRecogData
NAME
xcRecogData -- Scan input buffer for known archiver type
SYNOPSIS
result = xcRecogData(size, buffer, xadMasterBase)
D0 D0 A1 A6
BOOL xcRecogData(ULONG, STRPTR, struct xadMasterBase *)
FUNCTION
Returns non zero when this buffer is part of a archive file
supported by this client. The recognition should be very stable.
It should be tested with lots of files. One wrong recognition
for 100000 files is acceptable.
INPUTS
size size of passed buffer
buffer buffer containing start of file to scan
RESULT
result - TRUE if archiver is recogniced, FALSE if not
SEE ALSO
Example sourcecodes, xadmaster.library/xadRecogFile(),
xadmaster.library/xadGetInfo()
xadClient/xcUnArchive xadClient/xcUnArchive
NAME
xcUnArchive -- write the required entry to destination
SYNOPSIS
result = xcUnArchive(ai, xadMasterBase)
D0 A0 A6
LONG xcUnArchive(struct xadArchiveInfo *, struct xadMasterBase *)
FUNCTION
This function dearchives one entry. The required entry is passed
in xai_CurFile or xai_CurDisk. A normal client will support only
one of the two possibilities, but clients using file and/or disk
archives are allowed as well. When writing disk data, the client
should write data in blocks with size of multiple sectorsize.
Although it should work, it is not recommended to write blocks
unequal to this.
Nearly all information you may need is stored in xadArchiveInfo
structure.
You may expect the entries to be unarchived in same order as they
are numbered, but it is not necessary!
Disk archivers may expect to be called again to dearchive an
entry, even if there is only one! So restore the file position
you need to unarchive.
INPUTS
ai master communication structure
RESULT
result - any of the XADERR codes or zero when all is ok.
SEE ALSO
Example sourcecodes, xadmaster.library/xadDiskunArc(),
xadmaster.library/xadFileUnArc()